package cm.mefobe.android.telecomcost.entities;

public enum TimePeriod {
	SECOND(1), MINUTE(2), HOUR(3), DAY(4), WEEK(5), MONTH(6), YEAR(7);

	private final int index;

	TimePeriod(int index) {
		this.index = index;
	}

	public int index() {
		return index;
	}

	public int inSeconds() {
		switch (index) {
		case 1:
			return 1;
		case 2:
			return 60;
		case 3:
			return 60 * 60;
		case 4:
			return 60 * 60 * 24;
		case 5:
			return 60 * 60 * 24 * 7;
		case 6:
			return 60 * 60 * 24 * 7 * 4;
		case 7:
			return 60 * 60 * 24 * 7 * 4 * 12;
		default:
			throw new IndexOutOfBoundsException();
		}
	}
	
	public float inMinutes() {
		switch (index) {
		case 1:
			return 1/60;
		case 2:
			return 1;
		case 3:
			return 60;
		case 4:
			return 60 * 24;
		case 5:
			return 60 * 24 * 7;
		case 6:
			return 60 * 24 * 7 * 4;
		case 7:
			return 60 * 24 * 7 * 4 * 12;
		default:
			throw new IndexOutOfBoundsException();
		}
	}

	@Override
	public String toString() {
		switch (index) {
		case 1:
			return "Second";
		case 2:
			return "Minute";
		case 3:
			return "Hour";
		case 4:
			return "Day";
		case 5:
			return "Week";
		case 6:
			return "Month";
		case 7:
			return "Year";
		default:
			throw new IndexOutOfBoundsException();
		}
	}
}
